package com.kelvin.paopao.module.login.login.bindAccount;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;

import com.kelvin.kelvinlib.utils.ToastUtil;
import com.kelvin.paopao.R;
import com.kelvin.paopao.injector.components.DaggerBindAccountComponent;
import com.kelvin.paopao.injector.modules.BindAccountModule;
import com.kelvin.paopao.module.base.BaseActivity;
import com.kelvin.paopao.widgets.CustomToolbar;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/7/14.
 */

public class BindAccountActivity extends BaseActivity<IBindAccountPresenter> {
    @BindView(R.id.custom_toolbar)
    CustomToolbar customToolbar;
    @BindView(R.id.et_phone)
    EditText etPhone;
    @BindView(R.id.et_password)
    EditText etPassword;

    private String wechat_id;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_bind_account;
    }

    @Override
    protected void initInjector() {
        DaggerBindAccountComponent.builder().bindAccountModule(new BindAccountModule(this))
                .build().inject(this);
    }

    @Override
    protected void initViews() {
        customToolbar.showBackIcon(this);

        wechat_id = getIntent().getStringExtra("wechat_id");
    }

    @Override
    protected void updateViews(boolean isRefresh) {

    }


    @OnClick(R.id.tv_login)
    public void onClick() {
        String userId = etPhone.getText().toString().trim();
        String password = etPassword.getText().toString().trim();
        if (TextUtils.isEmpty(userId) || TextUtils.isEmpty(password)) {
            ToastUtil.showToast(this, "请填写要绑定的账号密码");
            return;
        }
        mPresenter.bindAccount(userId, password, wechat_id);
    }

    public static void launch(Context context, String wechat_id) {
        Intent intent = new Intent(context, BindAccountActivity.class);
        intent.putExtra("wechat_id", wechat_id);
        context.startActivity(intent);
    }
}
